package test2;

import java.util.Arrays;

public class demo2 {
	//冒泡排序
	public static void main(String[] args) {
		int[] b = { 1, 8, 3, 7, 5, 6 };

		int[] sort =sort(b);
		System.out.println(Arrays.toString(sort));
	}
	
	public static int[] sort(int[] array) {
		for(int i=0;i<array.length-1;i++) {
			Boolean flag=false;
			int a=0;
			for (int j = 0; j < array.length-1-i; j++) {
				if (array[j]>array[j+1]) {
					a=array[j];
					array[j]=array[j+1];
					array[j+1]=a;
					flag=true;
				}
			}
			if (flag==false) {
				break;
			}
		}
		return array;
	}
	
}
